﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using Tree.Lifecycle;
using System.Reflection;
using System.Globalization;

namespace Tree.Configuration
{
    /// <summary>
    /// Object Initialization Configurator.
    /// </summary>
    public class ObjectConfiguration
    {
        private static ContainerConfiguration config = (ContainerConfiguration) ConfigurationManager.GetSection("container");

        private static ContainerElement ConfigurationFor(Type t)
        {
            foreach (ContainerElement el in config.Collection)
            {
                if (el.Impl.Equals(t.FullName))
                {
                    return el;
                }
            }
            return null;
        }

        /// <summary>
        /// Gets the configuration initial state for the parameterized Type.
        /// </summary>
        /// <param name="type">Type to get the ConfigurationState.</param>
        /// <returns>Initial ConfigurationState for the type.</returns>
        public static ConfigurationState GetStateCollection(Type type)
        {
            ContainerElement el = ObjectConfiguration.ConfigurationFor(type);
            return el.ElementStateCollection;
        }
    }
}
